package netty.demo.nio.selector.write.improve;

import lombok.SneakyThrows;

import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.SocketChannel;

/**
 * @author Zed
 * @description
 * @date 2022/10/24 20:29
 */
public class WriteClient {
    @SneakyThrows
    public static void main(String[] args) {
        SocketChannel socketChannel = SocketChannel.open();
        socketChannel.connect(new InetSocketAddress("localhost", 8080));
        //3.接受数据
        int count = 0;
        while (true) {
            ByteBuffer byteBuffer = ByteBuffer.allocate(1024 * 1024);
            count += socketChannel.read(byteBuffer);
            System.out.println(count);
            byteBuffer.clear();
        }
    }
}
